;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;	Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

FileCreateDir, %A_ScriptDir%\..\_bin\Update\
UpdateDir = %A_ScriptDir%\..\_bin\Update

RegRead, VSExec, HKCU, Software\Microsoft\VisualStudio\10.0_Config, InstallDir
RegRead, AHKExec, HKLM, Software\AutoHotkey, InstallDir
RegRead, NSISExec, HKEY_CLASSES_ROOT, NSIS.Script\shell\compile\command

StringReplace, NSISExec, NSISExec, `%1, %A_ScriptDir%\setup.nsi
StringReplace, NSISExec, NSISExec, nsisw, nsis

VSExec = "%VSExec%devenv.exe"
AHKExec = "%AHKExec%\Compiler\Ahk2Exe.exe"
Solution = "%A_ScriptDir%\..\Armory Viewer.sln"
FileList = "%UpdateDir%\..\ArmoryData.dll" "%UpdateDir%\..\ArmoryViewer.exe" "%UpdateDir%\..\Microsoft.WindowsAPICodePack.dll" "%UpdateDir%\..\Microsoft.WindowsAPICodePack.Shell.dll" "%UpdateDir%\..\UIControls.dll" "%UpdateDir%\..\es-ES"

RunWait, %VSExec% %SOLUTION% /build Release
RunWait, %AHKExec% /in "%A_ScriptDir%\Updater.ahk" /out "%A_ScriptDir%\..\_bin\Update\updater"
RunWait, 7z.exe a -tzip "%UpdateDir%\archive" %FileList%,,Hide
FileMove, %UpdateDir%\archive.zip, %UpdateDir%\archive
RunWait, %NSISExec%,,Hide
FileMove, %UpdateDir%\..\Setup.exe, %UpdateDir%\setup
